Skip to content

Transform/constructors #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 32 commits into from

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Sep 21, 2014

Constructor phase.

The first 10 commits or so are really in preparation of LambdaLift, which will be the phase after Constructors.
Constructors was moved before LambdaLift because the lambda lift logic becomes simpler if it can assume that
parameter accessors have already been converted to parameters in super calls. Without this it is very hard to get lambda lift for super calls right. Witness the implementation restrictions to this effect in scalac.

Review by @DarkDimius @gzm0

@odersky odersky force-pushed the transform/constructors branch 2 times, most recently from ac8c0e2 to 74528b9 Compare September 24, 2014 12:26
@DarkDimius DarkDimius force-pushed the transform/constructors branch from 74528b9 to fa09399 Compare October 11, 2014 06:39
@DarkDimius
Copy link
Contributor

there's one error in t296.
Pattern is Y-checked correctly after pattern-matcher, but after literalize it doesn't Y-check.
I didn't investigate why.

@DarkDimius DarkDimius force-pushed the transform/constructors branch 3 times, most recently from 236fb32 to c0da421 Compare October 11, 2014 06:45
…ories.

We better make this configurable. Because sometimes we want to compile only the files
in the immediate directory.
The idea to traverse with currently enclosing methid is also used in
LambdaLift and could be used elsewhere.
…lled.

Instead of requiring to be called a given phase, change the context if
that is not the case.
Lifting an application  `f(arg1).f(args)` requires lifting of the whole prefix
`f(arg1)`, because `f` might have a side effect.
Advantage: Can rename typed as well as untyped trees.
Previously, we determined the default getters solely from the method TermRef type.
This is wrong if the method is prefix is not a path -- the prefix of the term ref will be a
TypeRef and the getter selection will be a SelectFromType tree, which makes no sense.
It changes meaning drastically so should always be visible.
Some transformations encounter applications where new arguments ahve to be
supplied. The method type already accounts for these argument but the
Application node passed into TreeTransform#transformApply is constructed
with a cpy.Apply operation which does a type assignment. That type assignment
fails with a parameter mismatch unless relaxedTyping is on.
Environment parameters do not count in th eresult type.
The current formulation of lambda lift is easier to do if that's the case.
Need to drop all non-class type declarations.
Params are already added by Desugar. No special treatment needed here.
Besides primaryConstructor.typeParams is always empty, because term symbols
do not have type parameters.

The fix turns t2660.scala into an error. I believe the error is correct, hence
the test was moved with a comment to neg.
Primary constructor was picking last constructor instead of first one.
This is now fixed. Also, added paramAccessors utility method.
Needed to fix a problem in CapturedVars to make this work.
Like the corresponding parameters, these also need to be rewritten to function types.
odersky and others added 9 commits October 11, 2014 19:33
1) Type parameters are now copied to accessors
2) Constructors also work for traits

2) makes it possible do to mixin after constructors.
TypeVars can appear as keys in baseType caches. The problem is that
their base types depend on their instantiation, which is not always
know yet when the test is performed. So results of baseType on
type variables should never be cached.

Todo: check whether there are any other caching problems involving typevars.
Typevars can be parts of larger types or underlying types of
other types, which renders these other types uncacheable. The new
logic takes account of that.
Private fields that are accessed only from the constructor,
and are accessed only after they are properly initialized are now
moved into the constructor. This avoids creating a redundant objetc field.
Good example: gcd in Rationals (see constrs.scala).
A cast like

    expr.asInstanceOf[x.type]

where x is a by-name parameter has to be mapped to

    expr.asInstanceOf[x.type].apply()

See pos/t296.scala which would otherwise start failing when the pattern matcher is integrated.
…ansform/constructors

Conflicts:
	src/dotty/tools/dotc/transform/ElimByName.scala
@odersky
Copy link
Contributor Author

odersky commented Oct 26, 2014

Superseded by #187

@odersky odersky closed this Oct 26, 2014
OlivierBlanvillain pushed a commit to OlivierBlanvillain/dotty that referenced this pull request Dec 12, 2016
WojciechMazur pushed a commit to WojciechMazur/dotty that referenced this pull request Mar 19, 2025
Backport "Connect the input to the compiler in `sbt`" to 3.3 LTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants